package com.mzj.saas.mservice.enterprise.repository;

import com.mzj.saas.mservice.enterprise.entity.UserStatistics;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface EnterpriseDataRepository extends PagingAndSortingRepository<UserStatistics, Long>, JpaSpecificationExecutor<UserStatistics> {

    @Query(value = "select * from saas_enterprise_user_statistics where org_id = ?1 order by\t stat_time Desc limit 1",nativeQuery = true)
    UserStatistics findByOrgIdOrderByStatTimeDescLimit(Long orgId);

    List<UserStatistics> findByOrgIdOrderByStatTimeDesc(Long orgId);

}
